package org.ws.task.schedule;

/**
 * 调度状态
 */
public enum ScheduleStatus {
    READY(true),
    /**
     * Indicates that processing can continue.
     */
    CONTINUABLE(true),
    /**
     * Indicates that processing is finished (either successful or unsuccessful)
     */
    FINISHED(false),
    /**
     *
     */
    STOP(false);

    private final boolean continuable;

    private ScheduleStatus(boolean continuable) {
        this.continuable = continuable;
    }

    public static ScheduleStatus continueIf(boolean continuable) {
        return continuable ? CONTINUABLE : FINISHED;
    }

    public boolean isContinuable() {
        return this == CONTINUABLE || this == READY;
    }

    public ScheduleStatus and(boolean value) {
        return value && continuable ? CONTINUABLE : FINISHED;
    }
}
